#include "stdio.h"
#include "threadpool.h"
#include "pthread.h"
#include "unistd.h"
#include "stdlib.h"

void taskFunc(void *arg)
{
    int num=*(int*)arg;//解引用得到内存地址里的数据
    printf("thread %ld is working,number = %d\n",pthread_self(),num);
    sleep(1);

}

int main()
{
    //创建线程池,最小3个最大10个容量100
    ThreadPool *pool=threadPoolCreate(3,10,100);
    for(int i=0;i<100;i++)//添加100个任务
    {
        int* num=(int*)malloc(sizeof(int));
        *num=i + 100;
        threadPoolAdd(pool,taskFunc,num);
    }

    sleep(30);
    threadPoolDestroy(pool);
    return 0;
}